from Base.PublicFunction import OpenBroswer
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
class TeachingManagement():
    def __init__(self):
        self.driver = OpenBroswer.openbrower()
        self.driver.get('http://10.10.10.171:8080/WoniuBoss4.0/login')
        self.driver.find_element_by_name('userName').send_keys('WNCD000')
        self.driver.find_element_by_name('userPass').send_keys('woniu123')
        self.driver.find_element_by_xpath('/html/body/div[1]/div/div/div[2]/button').click()

    def findElement(self, locator):
        ele = WebDriverWait(self.driver, 10, 0.1).until(EC.presence_of_element_located(locator))
        return ele


    # def get_username_ele(self):                      # 定位用户名
    #     locator = (By.NAME, "userName")
    #     ele = self.findElement(locator)
    #     return ele
    #     # return self.driver.find_element_by_name('userName')
    #
    # def get_password_ele(self):                      # 定位密码
    #     locator = (By.NAME, "userPass")
    #     ele = self.findElement(locator)
    #     return ele
    #     # return self.driver.find_element_by_name('userPass')
    #
    # def get_verifycode_ele(self):                    # 定位验证码
    #     locator = (By.NAME, "checkcode")
    #     ele = self.findElement(locator)
    #     return ele
    #     # return self.driver.find_element_by_name('checkcode')
    # #
    # def get_login_button_ele(self):                 # 定位登录按钮
    #     locator = (By.CLASS_NAME, "btn.btn-primary.btn-block.btn-save")
    #     ele = self.findElement(locator)
    #     return ele
        # return self.driver.find_element_by_class_name('btn.btn-primary.btn-block.btn-save')

    def get_teaching_management_ele(self):           # 定位教学管理
        locator = (By.LINK_TEXT, "教学管理")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_link_text("教学管理")

    def get_overtime_apply_ele(self):                # 定位加班申请
        locator = (By.LINK_TEXT, "加班申请")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_link_text('加班申请')

    def get_add_button_ele(self):                    # 定位加班申请中新增按钮
        locator = (By.CLASS_NAME, "btn.btn-primary.btn-padding.pull-right")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_class_name('btn.btn-primary.btn-padding.pull-right')

    def get_apply_start_time(self):                 # 定位加班申请开始时间输入框
        locator = (By.NAME, "apply.start_time")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_name('apply.start_time')

    def get_start_day_ele(self):                         # 定位加班申请开始时间日期选择
        locator = (By.XPATH, "/html/body/div[11]/div[3]/table/tbody/tr[4]/td[3]")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_xpath('/html/body/div[11]/div[3]/table/tbody/tr[4]/td[3]')

    def get_start_hour_ele(self):                        # 定位加班申请开始时间小时选择
        locator = (By.XPATH,"/html/body/div[11]/div[2]/table/tbody/tr/td/fieldset[2]/span[4]")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_xpath("/html/body/div[11]/div[2]/table/tbody/tr/td/fieldset[2]/span[4]")

    def get_start_minute_ele(self):                     # 定位加班申请开始时间分钟时间
        locator = (By.XPATH, "/html/body/div[11]/div[1]/table/tbody/tr/td/fieldset/span[2]")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_xpath("/html/body/div[11]/div[1]/table/tbody/tr/td/fieldset/span[2]")

    def get_apply_end_time(self):                    # 定位加班申请结束时间输入框
        locator = (By.NAME, "apply.end_time")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_name('apply.end_time')

    def get_end_day_ele(self):                      # 定位加班申请结束时间日期选择
        locator = (By.XPATH, "/html/body/div[12]/div[3]/table/tbody/tr[4]/td[3]")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_xpath('/html/body/div[12]/div[3]/table/tbody/tr[4]/td[3]')

    def get_end_hour_ele(self):                         # 定位加班申请结束时间小时选择
        locator = (By.XPATH, "/html/body/div[12]/div[2]/table/tbody/tr/td/fieldset[2]/span[6]")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_xpath("/html/body/div[12]/div[2]/table/tbody/tr/td/fieldset[2]/span[6]")

    def get_end_minute_ele(self):                      # 定位加班申请结束时间分钟选择
        locator = (By.XPATH, "/html/body/div[12]/div[1]/table/tbody/tr/td/fieldset/span[2]")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_xpath("/html/body/div[12]/div[1]/table/tbody/tr/td/fieldset/span[2]")

    def get_apply_accounting_way_ele(self):               # 定位加班申请核算方式
        locator = (By.NAME, "apply.accounting_way")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_name('apply.accounting_way')

    def get_belong_region(self):                       # 定位区域
        locator = (By.NAME, "apply.region_id")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_name('apply.region_id')

    def get_apply_reason_ele(self):                      # 定位加班原因
        locator = (By.NAME, "apply.reason")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_name('apply.reason')

    def get_submit_button_ele(self):                   # 定位提交按钮
        locator = (By.ID, "addApplyBtn")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_id('addApplyBtn')

    def get_confirm_button(self):                     # 定位确定按钮
        locator = (By.XPATH, "/html/body/div[14]/div/div/div[3]/button")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_xpath("/html/body/div[14]/div/div/div[3]/button")

    def get_apply_reason_clue(self):                 # 定位申请原因错误提示
        locator = (By.CLASS_NAME, "bootbox-body")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_class_name('bootbox-body')

    def get_exit_reason_clue(self):                 # 定位提示退出
        locator = (By.CLASS_NAME, "bootbox-close-button.close")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_class_name('bootbox-close-button.close')

    def get_exit_apply(self):                      # 定位申请单退出
        locator = (By.XPATH, "/html/body/div[14]/div/div/div[1]/button/span[1]")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_xpath('/html/body/div[14]/div/div/div[1]/button/span[1]')

    def get_apply_table_ele(self):                  # 定位申请表格
        locator = (By.ID, "apply-table")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_id('apply-table')

    def get_on_duty_ele(self):                     # 教师值班
        locator = (By.LINK_TEXT, "教师值班")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_link_text('教师值班')

    def get_assign_work_ele(self):                 # 指定值班
        locator = (By.CLASS_NAME, "btn.btn-primary.btn-padding.pull-right")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_class_name('btn.btn-primary.btn-padding.pull-right')

    def get_workman_select_ele(self):            # 定位值班人下拉框
        locator = (By.CLASS_NAME, "sel-text.work_id")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_class_name('sel-text.work_id')

    def get_workdata_ele(self):                 # 定位值班日期
        locator = (By.CLASS_NAME, "text.date.form-control.duty_time")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_class_name('text.date.form-control.duty_time')

    def get_date_ele(self):                 # 点击值班日期
        locator = (By.XPATH, "/html/body/div[15]/div[3]/table/tbody/tr[4]/td[3]")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_xpath("/html/body/div[15]/div[3]/table/tbody/tr[4]/td[3]")

    def get_dutyinfo_save_ele(self):              # 保存值班信息
        locator = (By.XPATH, "/html/body/div[16]/div/div/div[3]/button")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_xpath("/html/body/div[16]/div/div/div[3]/button")

    def get_dutyinfo_confirm_ele(self):        # 值班信息确认
        locator = (By.XPATH, "/html/body/div[16]/div/div/div[3]/button")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_xpath('/html/body/div[16]/div/div/div[3]/button')

    def get_dutyinfo_table_ele(self):         # 定位值班信息表格
        locator = (By.ID, "duty_table")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_id('duty_table')

    def closeBrowser(self):
        self.driver.close()



    def get_sys_management_ele(self):     # 定位系统管理
        locator = (By.LINK_TEXT, "系统管理")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_link_text('系统管理')

    def get_user_management(self):       # 定位用户管理
        locator = (By.LINK_TEXT, "用户管理")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_link_text('用户管理')

    def get_employee_name_ele(self):    # 定位员工姓名输入框
        locator = (By.NAME, "empName")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_name('empName')

    def get_query_button_ele(self):    # 定位查询按钮
        locator = (By.XPATH, "//*[text()='查询']")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_xpath('//*[text()="查询"]')

    def get_sys_emloyee_query_table_ele(self):     # 定位系统管理员工查询结果表格
        locator = (By.ID, "user-table")
        ele = self.findElement(locator)
        return ele
        # return self.driver.find_element_by_id('user-table')
